package com.fyt.reachgo.controller;

import com.fyt.reachgo.domain.Result;
import com.fyt.reachgo.domain.UserDisinterest;
import com.fyt.reachgo.domain.UserFavorite;
import com.fyt.reachgo.service.LikeService;
import com.fyt.reachgo.service.TravelGuideService;
import com.fyt.reachgo.service.UserFavoriteService;
import com.fyt.reachgo.service.impl.UserDisinterestServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author fyt
 * 获取旅游攻略
 */
@RestController
@RequestMapping("/TravelGuide")
@RequiredArgsConstructor
public class TravelGuideController {

    private final TravelGuideService travelGuideService;

    private final UserDisinterestServiceImpl userDisinterestService;

    private final LikeService likeService;

    private final UserFavoriteService  userFavoriteService;


    /**
     * 添加旅游攻略
     * @return
     */
    @RequestMapping("/addTravelGuide")
    public Result addTravelGuide() {
        return null;
    }

    /**
     * 获取路书列表
     * @param params
     * @return
     */
    @RequestMapping("/getTravelGuide")
    public Result getAllTravelGuide(@RequestBody Map<String, Object> params) {
        return travelGuideService.getTravelGuideList(params);
    }

    /**
     * 根据id获取旅游攻略
     * @param params
     * @return
     */
    @RequestMapping("/getTravelGuideById")
    public Result getTravelGuideById(@RequestBody Map<String, Object> params) {
        return travelGuideService.getTravelGuideById(params);
    }

    /**
     * 点赞路书
     * @param userId
     * @param guideId
     * @return
     */
    @PostMapping("/toggleLike")
    public Result<Boolean> toggleLike(@RequestParam Long userId, @RequestParam Integer guideId) {
        return likeService.toggleLike(userId, guideId);
    }
    /**
     * 收藏路书
     */
    @PostMapping("/collect")
    public Result collect(@RequestBody UserFavorite userFavorite) {
        return userFavoriteService.addCollect(userFavorite);
    }
    /**
     * 查看收藏路书
     */
    @PostMapping("/getCollects")
    public Result getCollects() {
        return userFavoriteService.getCollects();
    }

    /**
     * 不感兴趣接口
     * @param userDisinterest
     * @return
     */
    @PostMapping("/userUnLike")
    public Result userUnLike(@RequestBody UserDisinterest userDisinterest) {
        return userDisinterestService.userUnLike(userDisinterest);
    }

    @PostMapping("/tanT")
    public Result tanT() {
        return travelGuideService.tanTList();
    }

}
